package org.person.test.service.impl;


import org.person.basic.service.impl.BaseServiceImpl;
import org.person.test.domain.Role;
import org.person.test.dto.RolePermissionDTO;
import org.person.test.mapper.RoleMapper;
import org.person.test.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author stark
 * @since 2023-12-01
 */
@Service
public class RoleServiceImpl extends BaseServiceImpl<Role> implements IRoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public void saveAuth(RolePermissionDTO dto) {
        // 方案一 删除这一下 dto中的对应id 不存在的 list
        // 方案二 将dto中id的相关数据全删了 在重新写
        roleMapper.deleteAuth(dto.getId());
        if (dto.getPermissions().size() != 0){
            roleMapper.saveAuth(dto);
        }

    }

    @Override
    public List<Long> queryPermissionById(Long id) {
        return roleMapper.queryPermissionById( id);
    }
}
